import { observable, action, useStrict, computed, asMap, toJS } from 'mobx';
import BaseStore from './BaseStore';
import { chooseExceptionOperator } from '../apis/form';
import { Form } from 'weaver-mobile-page';

const initState = {
    form: null,
    callback: null
}

export class EhOperatorStore extends BaseStore{

    @observable form;
    callback;

    constructor(){
        super();
        this.changeState(initState);
        this.doEhInit = this.doEhInit.bind(this);
    }

    doEhInit(location){
        const { pathname,params,callback } = location;
        this.callback = callback;
        this.form = new Form.Store({ route: pathname });
        chooseExceptionOperator(params).then(datas =>{
            const { fields,formValue } = datas;
            this.form.initForm(fields, pathname);
            this.form.updateFields(formValue);
        });
    }

}